This callback function gets called whenever ActiveTick receives a response from a trading broker to previously placed order.
onOrder(order, orderResults);
order
Instance of Order object filled with details about the order.
orderResults
Instance of OrderResults object filled with result details about the order.
This callback is useful to receive status indications wether the order placement has successfully been processed, or if it has failed.
The following example demonstrates the use of onOrder() callback function.
function start()
{
//retrieve short positions for all symbols
var account = getAccount();
var placeLongOrder = false;
//determine whether a long order needs to be placed
..
..
..
if(placeLongOrder)
{
var rc = account.placeMarketOrder(getSymbol(),
parseFloat(getParameter("Default Trading Size")),
ACTIONTYPE_BUY,
TIFTYPE_DAY);
}
}
function onOrder(order, orderResults)
{
//process order results
if(getSymbol() != order.getSymbol())
return;
if(orderResults.getErrors().length == 0)
{
//order was placed successfully
..
..
}
else
{
//order failed
..
..
}
}
placeOrder(), getAccount(), getSymbol(), Account Class, Order Class, OrderResults Class
Copyright © 2006-2009 ActiveTick LLC